package service_sys

import (
	"fmt"
	"wrblog-api-go/app/common/token"
	"wrblog-api-go/app/dao/dao_sys"
	"wrblog-api-go/app/model/model_sys"
	"wrblog-api-go/pkg/mylog"
	"wrblog-api-go/pkg/utils"
)

// AddLoginiforOk 添加登录日志
func AddLoginiforOk(clientInfo token.ClientInfo, ak string, msg string) {
	logininfor := &model_sys.SysLogininfor{
		Status:     "0",
		Ak:         ak,
		ClientInfo: clientInfo,
		Msg:        msg,
		AccessTime: utils.NewTimeNow(),
	}
	err := dao_sys.AddLoginifor(logininfor)
	if err != nil {
		mylog.MyLog.Error(fmt.Sprintf("登录日志添加失败！%s", err))
	}
}

// AddLoginiforErr 添加登录日志
func AddLoginiforErr(clientInfo token.ClientInfo, ak string, msg string) {
	logininfor := &model_sys.SysLogininfor{
		Status:     "1",
		Ak:         ak,
		ClientInfo: clientInfo,
		Msg:        msg,
		AccessTime: utils.NewTimeNow(),
	}
	err := dao_sys.AddLoginifor(logininfor)
	if err != nil {
		mylog.MyLog.Error(fmt.Sprintf("登录日志添加失败！%s", err))
	}
}
